<?php

class Model_Advertisement extends Zend_Db_Table_Row
{

	public function getPhotoPhysicalPath($size=null) {
		$origFile = PUBLIC_PATH . '/images/advertisements/' . $this->image;
		if (empty($size)) {
			return $origFile;
		}
		$resizedFile = PUBLIC_PATH . '/images/advertisements/' . $size . '_' . $this->image;
		if (!file_exists($resizedFile) && is_readable($origFile)) {
			ImageHelper::resize($origFile, $resizedFile, $size);
		}
		return $resizedFile;
	}
	
	public function getPhotoWebAccessablePath($size=null) {
		if (empty($size)) {
			return '/images/advertisements/' . $this->image;
		}
		$this->getPhotoPhysicalPath($size);
		return '/images/advertisements/' . $size . '_' . $this->image;
	}

}

